"""
进程之间,没有资源竞争
线程之间资源竞争
"""
# from threading import Thread
# import time
# def func(x1):
#     x1.append(4)
#     print('我是func', x1)
# def function(x2):
#     print('我是function', x2)
# x = [1, 2, 3]
# if __name__ == '__main__':
#     Thread(target=func, args=(x,)).start()
#     Thread(target=function, args=(x,)).start()
#--------------------------------------------------------
# from threading import Thread
# import threading
# import time
# x = ['a', 'b', 'c']
# def func(num):
#     global x
#     mutex.acquire()  # 上锁
#     time.sleep(2)
#     for i in range(num):
#         x.append(i)
#     print('我是func', x)
#     mutex.release()  # 解锁
# def function(num):
#     global x
#     mutex.acquire()  # 上锁
#     time.sleep(2)
#     for i in range(num):
#         x.append(i)
#     print('我是function', x)
#     mutex.release()  # 解锁
# if __name__ == '__main__':
#     # 全局解释器锁,又叫GIL解释器锁
#     mutex = threading.Lock()
#     Thread(target=func, args=(3,)).start()
#     Thread(target=function, args=(5,)).start()
#-------------------------------------------------